[linux] fix: memory-mapped file, stat: No such file or directory #329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the bug
Since lsof-4.96.0, run lsof with old linux kernel (e.g. linux-2.6),
lsof would print error message "stat: No such file or directory"
when visiting memory-mapped files; but /bin/stat could visit it without issue.
lsof-4.95.0 and earlier does not have this issue.
In old linux kernel (e.g. linux-2.6) which does not have this feature: Commit
6b4e306aa3dc ("ns: proc files for namespace naming policy."), means this path
"/proc/self/ns" is not existed. Since lsof-4.96.0 with Commit dbad150 ("
[linux] obtain correct information of memory-mapped file."), compare_mntns()
would misunderstand it is in a different mount namespace if "/proc/self/ns" is
not existed, returns -1, go through map_files lookup, and finally lead to lsof
gets failed with error message "stat: No such file or directory".
If "/proc/self/ns" or its underlying path is not existed, compare_mntns()
returns 0 instead of -1, in order to go through stat_directly as old days.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should not print 'stat: No such file or directory'.
Program output
Environment (please complete the following information):